﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HZ.Supervise.Web.Common
{
    public partial class FindAllProductName1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            dataBind();
            if (IsPostBack)
            {
                bindList();
            }
        }
        /// <summary>
        /// 绑定GridView
        /// by张雄  2011.5.9
        /// </summary>
        public void dataBind()
        {
            AspNetPager1.PageSize = 5;
            HZ.Supervise.BLL.BLL_ProcureCatalog pro = new HZ.Supervise.BLL.BLL_ProcureCatalog();
            Model.Query.ProcureCatalog mpro = new HZ.Supervise.Model.Query.ProcureCatalog();
            int count = 0;
            if (!string.IsNullOrEmpty(this.txtProName.Text.Trim()))
            {
                mpro.ProductName = DAL.DAL_Helper.Replace(this.txtProName.Text.Trim());
            }
            //if (!string.IsNullOrEmpty(txtProID.Text.Trim()))
            //{
            //    mpro.ProcureCatalogID = DAL.DAL_Helper.Replace(this.txtProID.Text.Trim());
            //}

           
            if (!string.IsNullOrEmpty(txtCompanyName_SC.Text.Trim()))
            {
                mpro.CompanyName_SC = DAL.DAL_Helper.Replace(this.txtCompanyName_SC.Text.Trim());
            }

            //if (!(this.dropSortSource.SelectedValue.Equals("-1")))
            //{
            //    mpro.SortSource = Convert.ToInt32(DAL.DAL_Helper.Replace(this.dropSortSource.SelectedValue));
            //}
            //if (!string.IsNullOrEmpty(txtComPs.Text.Trim()))
            //{
            //    mpro.CompanyName_SC = DAL.DAL_Helper.Replace(txtComPs.Text.Trim());
            //}
            mpro.SortFields = "ProcureCatalogID ";
            this.gvwProList.DataSource = pro.GetProcureCatalogByWhere(mpro, AspNetPager1.CurrentPageIndex, this.AspNetPager1.PageSize, out count);
            this.gvwProList.DataBind();
            this.AspNetPager1.RecordCount = count;
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            dataBind();
        }
        protected void btnQery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            dataBind();
        }

        /// <summary>
        /// 绑定List控件集合
        /// </summary>
        private void bindList()
        {
            string[] proName = this.ProName.Value.Split(',');
            string[] proId = this.ProId.Value.Split(',');
            this.ListPro.Items.Clear();
            for (int i = 0; i < proName.Length; i++)
            {
                if (proName[i].Equals(""))
                {
                    return;
                }
                ListItem item = new ListItem();
                item.Text = proName[i];
                item.Value = proId[i];
                this.ListPro.Items.Add(item);
            }
        }
    }
}
